<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <search ref='search' :config='searchConfig' @search='search' @getHeight='getHeight' />

    <!-- table区域-begin -->
    <vxe-grid
      ref='xGrid'
      v-bind='vexConfig'
      :align='left'
      :border='true'
      :checkbox-config="checkboxConfig"
      :columns='columns'
      :data='dataSource'
      :height='pageHeight-seachHeight-94'
      :loading='loading'
      :resizable='true'
      :showOverflow='true'
      :toolbar-config="tableToolbar"
      size='mini'
      @checkbox-change='selectChangeEvent'
      @checkbox-all="selectChangeEvent"
    >
      <template  #action='{ row,rowIndex }'>
        <!--          <a v-has="'getGoodsAdress:update'" @click='handleEdit(row)'>编辑</a>-->
        <!--          <a-divider type='vertical' />-->
        <a-dropdown>
          <a class='ant-dropdown-link'>更多
            <a-icon type='down' />
          </a>
          <a-menu slot='overlay'>
            <a-menu-item>
              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(row.id)">
                <a>删除</a>
              </a-popconfirm>
            </a-menu-item>
          </a-menu>
        </a-dropdown>
      </template>
      <template #pager>
        <vxe-pager
          :currentPage.sync='ipagination.current'
          :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
          :page-size.sync='ipagination.pageSize'
          :pageSizes='ipagination.pageSizeOptions'
          :total='ipagination.total'
          @page-change='handlePageChange'>
        </vxe-pager>
      </template>
    </vxe-grid>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <newAdd ref="modalForm" @ok="modalFormOk"></newAdd>

  </a-card>
</template>

<script>
import newAdd from './modules/newAdd'
import JSuperQuery from '@/components/cn-form/JSuperQuery.vue';
import JInput from '@/components/cn-form/JInput.vue';
import {initDictOptions, filterDictText,filterDictTextByCache} from '@/components/dict/CnDictSelectUtil'
import { PageListMixin } from '@/mixins/PageListMixin'
import Vue from 'vue'
import { filterObj } from '@/utils/util';
import JTreeSelect from '@/components/cn-form/JTreeSelect'
import { postAction } from '../../../api/manage'
//高级查询modal需要参数
// const superQueryFieldList=[
//   {
//     type: "string",
//     value: "name",
//     text: "用户名"
//   }, {
//     type: "int",
//     value: "age",
//     text: "年龄"
//   }, {
//     type: "date",
//     value: "birthday",
//     text: "生日"
//   }
// ]
export default {
  name: "terminalBuy",
  mixins:[PageListMixin],
  components: {
    JSuperQuery,
    JInput,
    JTreeSelect,
    newAdd,
  },
  data() {
    return {
      description: '终端可购清单',
      //字典数组缓存
      sexDictOptions: [],
      searchConfig: [
        {
          type: 'input',
          name: 'code',
          placeholder: '请输入组织编号'
        },
        {
          type: 'input',
          name: 'name',
          placeholder: '请输入组织名称'
        },
        {
          type: 'input',
          name: 'productCode',
          placeholder: '请输入商品编号'
        },

      ],
      importExcelUrl:`${window._CONFIG['domianURL']}/test/cn-formDemo/importExcel`,
      //列设置
      settingColumns:[],
      //表头
      columns: [
        {
          width:60,
          fixed: 'left',
          type:'checkbox',
        },
        {
          title: '可购规则编号',
          minWidth:80,
          field: 'ruleCode',
        },
        {
          title: '组织编号',
          minWidth:80,
          field: 'code',
        },
        {
          title: '组织名称',
          minWidth:80,
          field: 'name'
        },
        {
          title: '商品编号',
          minWidth:80,
          field: 'productCode'
        },
        {
          title: '商品名称',
          minWidth:80,
          field: 'productName',
        },
        {
          title: '创建人',
          minWidth:80,
          field: 'createName'
        },
        // {
        //   title: '经销商组织',
        //   align: "center",
        //   field: 'custName'
        // },
        {
          title: '创建时间',
          minWidth:80,
          field: 'createTime'
        },
        // {
        //   title: '最近更新人',
        //   minWidth:80,
        //   field: 'updateName',
        //   ellipsis: true
        // },
        // {
        //   title: '最近更新时间',
        //   minWidth:80,
        //   field: 'updateDate',
        //   ellipsis: true
        // },
        {
          title: '操作',
          field: 'action',
          minWidth:80,
          fixed:'right',
          width: 120,
          slots: { default: 'action' },
        }
      ],
      url: {
        list:  window._CONFIG['domianDmsURL'] + "/custProduct/findPageListTerminal",
        delete:  window._CONFIG['domianDmsURL'] + "/custProduct/deleteByIdClient",
        deleteBatch: "/test/cn-formDemo/deleteBatch",
        exportXlsUrl: "/test/cn-formDemo/exportXls"
      },
      // fieldList:superQueryFieldList
    }
  },
  created() {},
  methods: {
    getQueryParams(){
      //高级查询器
      let sqp = {}
      if(this.superQueryParams){
        sqp['superQueryParams']=encodeURI(this.superQueryParams)
        sqp['superQueryMatchType'] = this.superQueryMatchType
      }
      var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);

      param.field = this.getQueryField();
      param.current = this.ipagination.current;
      param.size = this.ipagination.pageSize;
      delete param.birthdayRange; //范围参数不传递后台
      return filterObj(param);
    },

  },

}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>